home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog7.arj / STRDEMO2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.8 KB  |  64 lines

  1. { strdemo2.pas -- Dynamic importing demonstration }
  2.  
  3. program StrDemo2;
  4.  
  5. uses WinTypes, WinProcs, WinCrt, Strings;
  6.  
  7. type
  8.  
  9.   TStrNCopy = function(Source: String; var P: PChar): PChar;
  10.   TStrTok = function(var Next: PChar; P: PChar; C: Char): PChar;
  11.   TStrFill = procedure(P: PChar; C: Char; Size: Word);
  12.  
  13. var
  14.  
  15.   HStr: THandle;
  16.   StrNCopy: TStrNCopy;
  17.   StrTok: TStrTok;
  18.   StrFill: TStrFill;
  19.   Next: PChar;
  20.  
  21. {- Variables from StrDemo1 (plus P) }
  22.  
  23.   Buffer: array[0 .. 80] of Char;
  24.   P, DeviceName, DriverName, OutputName: PChar;
  25.   A: array[0 .. 40] of Char;
  26.  
  27. begin
  28.   HStr := LoadLibrary('STRDLL.DLL');
  29.   if HStr < 32 then
  30.     Writeln('*** Error loading STRDLL.DLL library file ***')
  31.   else begin
  32.     @StrNCopy := GetProcAddress(HStr, 'STRNCOPY');
  33.     @StrTok := GetProcAddress(HStr, 'STRTOK');
  34.     @StrFill := GetProcAddress(HStr, 'STRFILL');
  35.     GetProfileString('windows', 'device', ',,', Buffer, Sizeof(Buffer));
  36.     Writeln('Original string  = ', Buffer);
  37.     StrNCopy(Buffer, P);
  38.     if P <> nil then
  39.     begin
  40.       Writeln('Copy of original = ', P);
  41.       StrDispose(P)
  42.     end;
  43.     Next := nil;
  44.     DeviceName := StrTok(Next, Buffer, ',');
  45.     DriverName := StrTok(Next, nil, ',');
  46.     OutputName := StrTok(Next, nil, ',');
  47.     Writeln('Device name = ', DeviceName);
  48.     Writeln('Driver name = ', DriverName);
  49.     Writeln('Output name = ', OutputName);
  50.     Writeln;
  51.     StrFill(A, '-', SizeOf(A));
  52.     Writeln('Filled A = ', A);
  53.     Writeln;
  54.     Writeln('Press Alt+F4 to close window');
  55.     FreeLibrary(HStr)
  56.   end
  57. end.
  58.  
  59.  
  60. {--------------------------------------------------------------
  61.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  62.   Revision 1.00    Date: 5/25/1991
  63. ---------------------------------------------------------------}
  64.